<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            padding: 0px;
            margin: 0px;
        }

        .dd {
            width: 500px;
            margin: 100px auto;
        }

        input {
            margin-left: 3px;
        }

        button {
            width: 60px;
            height: 40px;
            margin-left: 10px;
            line-height: 40px;
        }
    </style>
    <script>
        window.onload = function () {
            var bts = document.getElementsByTagName("button");
            var inps = document.getElementsByTagName("input");
            bts[0].onclick = function () {
                for (let i = 0; i < inps.length; i++) {
                    inps[i].checked = true;

                }

            }
            bts[2].onclick = function () {
                for (let i = 0; i < inps.length; i++) {
                    inps[i].checked = !inps[i].checked;
                }
            }
            bts[1].onclick = function () {
                for (let i = 0; i < inps.length; i++) {
                    inps[i].checked = false;
                }
            }
        }

    </script>

</head>
<body>

<div class="dd">
    <button>全选</button>
    <button>取消</button>
    <button>反选</button>
    <ul>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>
        <li>选项<input type="checkbox"/></li>

    </ul>
</div>

</body>
</html>